package jdbc;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

/**
 * 
 * @author IBD, JMDSD
 *
 */
public class ConnectionJavaDB {
	
	/**
	 * 
	 */
	private static DataSource datasource;
	/**
	 * @return
	 */
	public static DataSource getInstance(){
		if(datasource == null){
			try{
				Context initCtx = new InitialContext();
				datasource = (DataSource) initCtx.lookup("java:comp/env/jdbc/ChezJMIDB");
			}catch(NamingException e){
				e.printStackTrace();
				System.err.println("Datasource indisponible");
			} 
		}
		return datasource;
	}

}
